#!/usr/local/gnu/bin/bash
# rundeja - invokes the dejagnu test framework
#
# Copyright 1994-2000 Wind River Systems, Inc.
#
# modification history
# -----------------------
# 02z,30oct00,mrs Fix WIND_BASE reference.
# 02y,18oct00,mrs Fix spelling of PENTIUM2.
# 02x,22sep00,s_l Update the script to build target systems for T3
# 02w,23aug00,s_l Update rundeja to do thumb work for T3.
# 02v,14aug00,mrs Document -build as not working.
# 02u,21jun00,mrs Fixed WIND_BASE refernce.
# 02t,21jun00,tdl added x86-linux2 support
# 02s,19jun00,s_l Move the new T3 build kernel to fixex a bug
# 02r,07jun00,s_l Modify scrip to build C++ kernels for T3
# 02q,20apr00,s_l More path filename updates for T3
# 02p,17apr00,tdl 00comp_dejagnu.cdf now stored under .../dejagnu
# 02o,05apr00,tdl Added -interactionLevel 0 to prjCreate commands
# 02n,04apr00,tdl Partial support for simpc testing
# 02m,31mar00,s_l Modify case statment for cpu type for simsolaris 
# 02l,29mar00,tdl pass ${cpu}gnu to prjCreate now
# 02k,22mar00,s_l Update call to wtxregd to start for T3
# 02j,03mar00,s_l Add flag -n to rsh calls to spped process
# 02i,03mar00,s_l Update script to copy objdump
# 02h,23feb00,tdl get testing working for NT compilers again
# 02g,17feb00,tdl added auto include INCLUDE_ for project
# 02f,17feb00,sl  new proj/* project directory names
# 02e,01feb00,tdl (ahem) finished -cpu option changes...
# 02d,31jan00,tdl added -cpu <CPU> option.
# 02c,18jan00,tdl get_makefile now copies makefile from wb_kernel
# 02b,18jan00,tdl Added mips CW4000
# 02a,16dec99,mrs Fix wtxregd invocation.
# 01z,29nov99,tdl -build now builds T3 kernel...
# 01y,17nov99,tdl start a Tornado registry if -registry not used
# 01x,15nov99,tdl pentium support split from i386 support
# 01w,12nov99,tdl initial mods for absolute minimal T3 support
# 01v,22oct99,tdl added gcc specific site generation stuff
# 01u,08oct99,tdl update WIND_REGISTRY_default
# 01t,08sep99,mrs update WIND_REGISTRY_default
# 01s,31aug99,mrs test the right compiler, and add thumb support
# 01r,31aug99,tdl added gcc testing
# 01q,26aug99,mrs default -test to /vobs/wpwr
# 01p,02apr99,tdl generated run.bat now contains WIND environment
# 01o,26mar99,tdl removed duplicate -D defines and now making "vxWorks"
#                 instead of "release" (to avoid building project junk)
# 01n,09mar99,tdl prepare for simulator testing
# 01m,27feb99,tdl Added PENTIUM cpu type support
# 01l,13jan99,dra Added SH-DSP support
# 01k,20oct98,mrs Stupid hack to make libio test on x86-win32 arm.
# 01j,20oct98,mrs Just the release target, not the vxWorks target,
#		  fixes pid7t_t testing.
# 01i,29sep98,tdl added multipass for library tests
# 01h,02sep98,sn  fixed up logic that checks user's .rhosts file for $board
# 01g,02sep98,sn  corrected typo in help
# 01f,11aug98,tdl grep for kernel,vxworks will now find just kernel,vxworks for
#                 i960 targets (i960 board files contained kernel,vxworks5.x
#                 as well.)
#                 make sure wind base is not thrown away for windows testing
# 01e,07aug98,tdl added clearcase tip to windows hints
#                 added $CAT - used for screen output
# 01d,31jul98,sn  completed autobuild (-build) feature
# 01c,31jul98,sn  added -update flag
# 01b,30jul98,sn  added autoverbosity feature
# 01a,23jul98,sn  written
#
# EXAMPLE:
# rundeja -board t22-174 -tool libio -test $WIND_BASE
#
# INTERNALS:
#
#
# GENERAL NOTES
# (1) For documentation on a variable search for <variable>= starting
#     from the top of the file. Some obviously named `local' variables
#     don't have comments.
# (2) Variables that denote booleans are regarded as TRUE iff they have
#     a non-empty value
# (3) Throughout we refer to LOCAL and REMOTE machines. These are
#     the same if we are testing unix executables. If we are
#     testing windows executables then the framework runs on unix
#     and we carefully provide `executables' which are actually
#     scripts that rsh into windows. In this case LOCAL is unix
#     and REMOTE is windows.
# (4) We use change_dir throughout instead of cd (except in
#     scripts that we generate of course).

# The name of this program
program=rundeja
# A directory all of our own
home_dir=$HOME/.${program}
mkdir -p $home_dir
# This is a timestamp file corresponding to when we start running.
# Some things need to be recreated each time we run the script
# but only once per run.
start_stamp=$home_dir/stamp
touch $start_stamp
# A flag indicating that a fatal error has occurred. The
# only point of continuing briefly is to generate a
# more helpful error analysis for the user. After doing
# so the function should call exit_nicely.
# Any function that may set this should include a comment to that effect.
quit=
# The location of clearcase cleartool.
cleartool=/usr/atria/bin/cleartool
# cat substitute
CAT=more
# Location of the global (prewritten) site.exp file. There is a also a
# tool specific site.exp file (generated by us) and a board
# specific ${board}.exp file (pregenerated). This variable
# is used by dejagnu (suprise, suprise!).
DEJAGNU=
# Location of target-board .exp files
boards_dir=
# Path to ${board}.exp itself (or a copy of it in our workspace).
# This file may be generated by the script itself or it may
# be one of the pregenerated ones.
board_exp=
# WIND_REGISTRY for all tornado tools
# Set using -registry
setting_registry=
WIND_REGISTRY=
# and the default
WIND_REGISTRY_default=`hostname`
#WIND_REGISTRY_default=queen
#WIND_REGISTRY_default=mustaine
# WIND_HOST_TYPE for the REMOTE host.
WIND_HOST_TYPE=


# The target board name (e.g. t22-174). The simulators have special names.
# They are : simsolaris, simhppa and simpc.
# Set using -board.
board=
# X10 controller ID for the board. This is only used if there
# isn't already a .exp file for $board.
# Set using -x10
X10_ID=
# BSP for the board. This is the appropriate subdirectory
# of target/config. For example mv1604. This is only used if
# there isn't already a .exp file for $board.
# Set using -bsp
bsp=
# The CPU flag must be set for T3 because of a chicken/egg
# type program. We try to get the CPU from the Makefile
# but in order to create Makefile with the project facility
# we need to pass CPU to it!
cpu=
# True if we shouldn't sanity check the users .rhosts file.
# Set using -ignore-rhosts.
ignore_rhosts=

# The tool that we are testing.
# Set using -tool.
tool=
# The architecture family of $board. Allowed values are
# 386, 960, 68k, ppc, arm, thumb, mips, sparc, simso, simhppa, simpc, sh
arch=
# Target triplet corresponding to $arch.
target_triplet=
# The host_triplet of LOCAL (we never tell dejagnu that it is testing windows!)
host_triplet=
# WIND_HOST_TYPE for the LOCAL machine
local_host=
# The gnu subdirectory containing the testsuite for $tool
testsuite_dir=
# A user supplied base directory that we can consider ours. This is
# where we do all our work. The executables used by the
# framework are ones that we place in this workspace.
# This directory must live on LOCAL and must be visible on REMOTE. See
# below for details.
# Set using -root
root_working_dir=
# and the default
root_working_dir_default=$HOME/dejatests
# Once we have gleaned enough information we start working
# in a situation specific directory defined as
# root_working_dir/$WIND_HOST_TYPE/$tool/$arch/$board
actual_working_dir=
# WIND_BASE for the tree that we want to test (as seen from REMOTE).
# If REMOTE=WINDOWS then this should have the form
# <drive>:/.../... (note forward slashes)
# Set using -test.
wb_test=
# WIND_BASE for the tree that contains the kernel.
# This may be on either unix or windows.
# In the windows case, this should have the form
# <drive>:/.../... (note forward slashes)
# Set using -kernel.
wb_kernel=
# True if wb_kernel is a windows path. We think a path
# is windowsy if it starts with <drive>:. Otherwise it is unixy
wb_kernel_is_on_windows=
# True if we should rebuild the kernel. In this case we build
# in $wb_kernel using the tools in $wb_kernel (as opposed to
# say the tools in $wb_test).
# False if the user has already built a kernel.
# True if -build.
must_rebuild_kernel=
# Location of (a copy of) the VxWorks kernel for $board.
kernel=
# WIND_BASE for the tree that contains the dejagnu framework and
# the expect binary (as seen from LOCAL, to run on same).
# Set using -dejagnu.
wb_dejagnu=
# and the default
wb_dejagnu_default=/view/wrs.tor3_0.daily/wind/river
# The directory that contains (a copy of) all the gnu subdirectories
# we need. They must all come from $wb_dejagnu of course but they
# may be copies that live in our workspace. The directories we
# need are dejagnu, tcl, and various bits of $testsuite_dir.
dj_gnu=
# A | seperated list of prefixes. The workspace copy of any gnu
# subdirectory matching one of these prefixes will be updated.
# Set (with spaces) using -update.
# The command parsing phase must call get_update_list to
# turn the spaces into |.
update_list=
# The location of (a copy of) the expect binary from the $wb_dejagnu tree
# for $local_host
EXPECT=
# WIND_BASE for the tree that contains the Target Server executable
# as seen from (arch = simpc ? REMOTE : LOCAL), to run on same.
# In that case it should be of the form
# <drive>:/.../... (note forward slashes).
# Set using -tgtsvr.
wb_tgtsvr=
# For a uniform treatment we define a WIND_BASE for the
# Target Server *as seen from unix*. Unless arch=simpc this
# is always $wb_tgtsvr. In the exceptional case we
# use a dummy value. The unix_to_windows function knows
# how to turn this back into the correct path.
wb_tgtsvr_as_seen_from_unix=
wb_virtual_tgtsvr=/ViRTuAl_TgTsVr
# WIND_BASE for the tree that contains the Wind Shell executable
# (as seen from LOCAL, to run on same).
# Set using -windsh.
wb_windsh=
# And the default
wb_windsh_default=/view/wrs.tor3_0.daily/wind/river
# Default wb_windsh for ARM or empty if it's the
# same as for other embedded arches.
wb_windsh_default_for_arm=
# This is a startup script that we pass to the Wind Shell
# It may need to do things like redirecting std i/o to the
# Wind Shell from the console.
windsh_script=
# We need to pass a WIND_BASE to the test framework.
# If ! $testing_windows this is $wb_test.
# If $testing_windows we use a dummy value. The `executables'
# called by the framework are actually scripts generated by
# us that know how to convert unix paths (including this
# virtual WIND_BASE) into windows paths.
wb_virtual_test=/ViRTuAl_TeSt
# This is the WIND_BASE we pass to the test framework. It is
# also the WIND_BASE we use to refer to the test tree in this
# script.
wb_framework=
# The current working directory on UNIX.
cwd_as_seen_from_unix=


#####################################################################
# Are we testing WINDOWS executables?
# True if either of the options -host or -map are used.
testing_windows=
# The following only apply if $testing_windows.

# The name of the REMOTE (windows) host
# Set using -host.
windows_host=
# The current working directory on UNIX as seen from WINDOWS -
# but with forward slashes instead of backslashes.
cwd_as_seen_from_windows=
# The user must ensure that $root_working_dir is visible on REMOTE.
# S/he then provides us with a unix to windows map of the form
# <unix_home>=<drive-letter>:
# Set using -map.
unix_to_windows_map=
# We decompose the above into a unix directory and a windows directory
# (the latter always has the form <drive-letter>:)
unix_home=
windows_home=
# We want to be able to invoke commands on windows that
# start in the correct directory ($cwd_as_seen_from_windows).
# We do this by creating a windows .bat file ($run_bat) that will
# receive our requests and process them in the correct
# environment.
# The requests may also come (indirectly) from the dejagnu framework.
# For example when dejagnu tries to compile something it will
# invoke xgcc. This will be a (unix) shell script which
# in turn runs the windows script (on $windows_host) with the appropriate
# command line as an argument.
# This is the location of the .bat file as seen from LOCAL (unix).
run_bat=
# <end $testing_windows specific>

# True if -verbose.
verbose_flag=
# True if -instrument. Used for debugging this script.
instrument=
# If $instrument then events are logged to this file
event_log=
# If $verbose_flag and $testing_windows we log a list of commands
# that were run on windows. They can be rerun at a dos prompt.
# This is the location as seen from LOCAL (unix).
windows_log=

#####################################################################
# These are flags that are passed to runtest
# Set to --debug if we are passed -debug.
debug_flag=
# Set to -v -v -v -v if we are passed -talkative. (-verbose
# makes this script verbose, while -talkative makes the
# test framework verbose).
talkative_flag=
# Set to whatever the user specifies with -other.
other_flags=

#####################################################################
# get functions
#
# Most variables whose values aren't supplied by the user have a get function.
# `get' doesn't actually output anything. It simply fills
# in the correct value, if necessary. Sometimes stuff is pulled
# into the workspace as a side effect.
# Some variables that the user supplies need to be massaged in some
# way. We do that here too.

# These ones only need to be calculated once and we may cache accordingly.

get_DEJAGNU ()
{
    event "get_DEJAGNU"
    get_dj_gnu
#    DEJAGNU=/net/flambeau/flambeau3/salim/dejagnu/site.exp
    DEJAGNU=$dj_gnu/dejagnu/site.exp
    event "DEJAGNU=$DEJAGNU"
}

get_boards_dir ()
{
    event "get_boards_dir"
    if [ -n "$boards_dir" ]; then return; fi
# Assume that the directory containing the ${board}.exp files
# is called `boards' and lives in the same directory as
# the global site.exp file.
# This says replace .../.../site.exp by .../.../boards
    get_DEJAGNU
    boards_dir=`echo $DEJAGNU | sed 's@/site.exp@@'`/boards
    event "boards_dir=$boards_dir"
}

get_board_exp ()
{
    event "get_board_exp"
    if [ -n "$board_exp" ]; then return; fi
    get_boards_dir
    board_exp=$boards_dir/${board}.exp
    if [ ! -r $board_exp ]; then
	assert "usage x10" $X10_ID
	assert "usage bsp" $bsp
	assert "usage cflags" $cflags
# If any of these arguments has not been provided then quit
	if [ -n "$quit" ]; then

	    exit_nicely;
	fi
	verbose "Generating ${board}.exp in $boards_dir"
	verbose "This will be used next time you invoke me."
	verbose "But you may want to stash this away somewhere more permanent."
	cat > $board_exp <<EOF
load_generic_config "vxworks"
set_board_info compiler "[find_gcc]";
set_board_info ldflags "-nostdlib -r";
set_board_info x10 $X10_ID
set_board_info "kernel,vxworks" \$WIND_BSPBASE/target/proj/${bsp}_vxWorks/${cpu}gnu.debug/boot.txt
set_board_info cflags "$cflags"
EOF
    fi
    event "board_exp=$board_exp"
}

get_WIND_HOST_TYPE ()
{
    event "get_WIND_HOST_TYPE"
    if [ -n "$WIND_HOST_TYPE" ]; then return;fi
    if [ -n "$testing_windows" ]; then
	WIND_HOST_TYPE=x86-win32
    else
	get_local_host
	WIND_HOST_TYPE=$local_host
    fi
    event "WIND_HOST_TYPE=$WIND_HOST_TYPE"
}

get_arch ()
{
    event "get_arch"
    if [ -n "$arch" ]; then return; fi
    get_makefile
# If -cpu not used, try the makefile for the cpu type.
    if [ -z "$cpu" ]; then
	 makefile=${wb_kernel}/target/config/${bsp}/Makefile
	cpu=`grep "CPU[	 ]*=" $makefile | \
	    sed 's/CPU[	 ]*=[	 ]*\([A-Z_0-9]*\).*$/\1/'`
    fi
    # This is an good example of bad code, please rewrite me.
    case $cpu in
	    PPC* ) arch=ppc ;;
	    R* | CW4000 | MIP* ) arch=mips ;;
	    I80* ) arch=386 ;;
	    PENTIUM* ) arch=pentium ;;
	    I960* ) arch=960 ;;
	    ARMARCH4 ) arch=arm ;;
	    ARMARCH4_T ) arch=thumb ;;
	    ARM7TDMI_T ) arch=thumb ;;
	    MC68* ) arch=68k ;;
	    SPARC* ) arch=sparc ;;
        SIMSPARCSOLARIS* ) arch=sparc ;;
        SIMNT* ) arch=pentium ;;
        SIMHPPA* ) arch=hppa ;;
	    SH* ) arch=sh ;;
	    * )
		echo "I can't guess the architecture the CPU $cpu."
		echo "Having problems finding CPU in $makefile"
		echo "for the $board or you need to define it"
		echo "using the -cpu command line option."
	        exit_nicely
		;;
    esac
    after_get_arch
    event "arch=$arch"
}

# (A copy of) the BSP Makefile for $board
makefile=

get_makefile ()
{
    event "get_makefile"
    if [ -n "$makefile" ]; then return; fi
    get_wb_kernel
    get_bsp_dir
    makefile=$cwd_as_seen_from_unix/Makefile
    remote_copy $wb_kernel/$bsp_dir/Makefile $makefile
    event "makefile=$makefile"
}

# The WIND_BASE relative path to the BSP for $board
bsp_dir=

get_bsp_dir ()
{
    event "get_bsp_dir"
    if [ -n "$bsp_dir" ]; then return; fi
    get_board_exp
# Look for the line set_board_info "kernel,vxworks" $WIND_BSPBASE/<bsp_dir>
# in the .exp file for $board. Here $WIND_BSPBASE is a string literal
# not the value of a variable!
#
# note: i960 boards have both kernel,vxworks and kernel,vxworks5.x info
#       we'll grab just kernel,vxworks and hope for the best...
#
#    bsp_dir=`grep 'set_board_info "kernel,vxworks"' $board_exp | \
#         sed 's@.* $WIND_BSPBASE/\(.*\)/vxWorks@\1@'`
    bsp_dir=`grep 'set_board_info "kernel,vxworks"' $board_exp | \
         sed 's@.* $WIND_BSPBASE/\(.*_vxWorks\)\(/.*\)@\1@'`
# if bsp not set via command line, extract it from .exp file...
    if [ -z "$bsp" ]; then
	bsp=`echo $bsp_dir | sed 's@.*target/proj/\(.*\)_vxWorks@\1@'`
    fi
    event "bsp_dir=$bsp_dir"
}

get_target_triplet ()
{
    event "get_target_triplet"
    get_arch
    # This is an good example of bad code, please rewrite me.
    case $arch in
	386 ) target_triplet=i386-wrs-vxworksae ;;
	pentium ) target_triplet=i586-wrs-vxworksae ;;
	960 ) target_triplet=i960-wrs-vxworks5.3 ;;
	68k ) target_triplet=m68k-wrs-vxworks ;;
	ppc ) target_triplet=powerpc-wrs-vxworksae ;;
	arm ) target_triplet=arm-wrs-vxworksae ;;
	thumb ) target_triplet=thumb-wrs-vxworksae ;;
	mips ) target_triplet=mips-wrs-vxworksae ;;
	sparc ) target_triplet=sparc-wrs-vxworksae ;;
        simso ) target_triplet=sparc-wrs-vxworksae ;;
        simpc ) target_triplet=i586-wrs-vxworksae ;;
        hppa ) target_triplet=hppa1.1-wrs-vxworks ;;
	sh ) target_triplet=sh-wrs-vxworks ;;
	* ) echo "I've never heard of this architecture (\`$arch')."
	    echo "(This may be a bug - :( -)."
	    exit_nicely
    esac
    event "target_triplet=$target_triplet"
}

get_host_triplet ()
{
    event "get_host_triplet"
    if [ -n "$local_host" ]; then return; fi
    os_string=`uname -a`
# Extract the leftmost string that starts with a digit and
# then consists of either digits or periods
    os_ver=`echo $os_string | sed 's/^[^0-9]*\([0-9][0-9\.]*\).*$/\1/'`
    # This is an good example of bad code, please rewrite me.
    case $os_string in
	SunOS* )
	    case $os_ver in
		5* )
# SunOs version 5.x.y is Solaris version 2.x.y
		    solaris_ver=`echo $os_ver | sed 's/^5/2/'`
		    host_triplet=sparc-sun-solaris$solaris_ver ;;
	    esac
	    ;;
	HP-UX* )
	    case $os_ver in
		10* ) host_triplet=hppa1.1-hp-hpux$os_ver ;;
	    esac
	    ;;
	Linux* )
	    case $os_ver in
# RedHat Linux v6.1
		2* ) host_triplet=i686-pc-linux-gnu ;;
	    esac
	    ;;
    esac
    event "host_triplet=$host_triplet"
}


get_local_host ()
{
    event "get_local_host"
    if [ -n "$local_host" ]; then return; fi
    get_host_triplet
    # This is an good example of bad code, please rewrite me.
    case $host_triplet in
	sparc-sun-solaris2* ) local_host=sun4-solaris2 ;;
	i686-*-linux* ) local_host=x86-linux2 ;;
	hppa1.1-hp-hpux10* ) local_host=parisc-hpux10 ;;
    esac
    event "local_host=$local_host"
}

get_testsuite_dir ()
{
    event "get_testsuite_dir"
    if [ -n "$testsuite_dir" ]; then return; fi
    case $tool in
	gcc ) testsuite_dir=gcc ;;
	g++ ) testsuite_dir=gcc ;;
	libio ) testsuite_dir=libio ;;
	libstdc++ ) testsuite_dir=libstdc++ ;;
    esac
    event "testsuite_dir=$testsuite_dir"
}

get_actual_working_dir ()
{
    event "get_actual_working_dir"
    if [ -n "$actual_working_dir" ]; then return; fi
    get_WIND_HOST_TYPE
    get_arch
    windows_safe_tool=`echo $tool | sed 's/+/x/g'`
    actual_working_dir=$root_working_dir/$WIND_HOST_TYPE/$windows_safe_tool/$arch/$board
    mkdir -p $actual_working_dir
    event "actual_working_dir=$actual_working_dir"
}

# True if $wb_test has been formatted to only contain forward slashes
wb_test_slashified=

get_wb_test ()
{
    event "get_wb_test"
    if [ -n "$wb_test_slashified" ]; then return; fi
    wb_test=`slashify $wb_test`
    wb_test_slashified=t
    event "wb_test=$wb_test"
}

# True if $wb_kernel has been formatted to only contain forward slashes
wb_kernel_slashified=

get_wb_kernel ()
{
    event "get_wb_kernel"
    if [ -n "$wb_kernel_slashified" ]; then return; fi
    wb_kernel=`slashify $wb_kernel`
    wb_kernel_slashified=t
    event "wb_kernel=$wb_kernel"
}

get_wb_kernel_is_on_windows ()
{
    event "get_wb_kernel_is_on_windows"
    if [ -n "$wb_kernel_is_on_windows" ]; then return; fi
    if [ -n "`echo $wb_kernel | grep '^[a-zA-Z]:'`" ]; then
	wb_kernel_is_on_windows=t
    fi
    event "wb_kernel_is_on_windows=$wb_kernel_is_on_windows"
}

get_kernel ()
{
    event "get_kernel"
    if [ -n "$kernel" ]; then return; fi
    get_bsp_dir
    get_actual_working_dir
#    kernel=$actual_working_dir/vxWorks
    kernel=$actual_working_dir
    get_wb_kernel_is_on_windows
    if [ -z "$wb_kernel_is_on_windows" ]; then
#	cp $wb_kernel/$bsp_dir/vxWorks $kernel
	cp -r $wb_kernel/$bsp_dir/${cpu}gnu.debug $kernel
    else
#        remote_copy $wb_kernel/$bsp_dir/vxWorks $kernel
	mkdir -p ${cpu}gnu.debug
        remote_copy $wb_kernel/$bsp_dir/${cpu}gnu.debug $kernel/${cpu}gnu.debug
    fi
    kernel=$kernel/${cpu}gnu.debug/boot.txt
    after_get_kernel
    event "kernel=$kernel"
}

# We copy the relevant portions of the dejagnu framework into
# our workspace.

get_dj_gnu ()
{
    event "get_dj_gnu"
    if [ -n "$dj_gnu" ]; then return; fi
# This is the directory that contains the originals of the
# gnu subdirectories we need.
    get_gnu
    get_testsuite_dir
    dj_gnu_orig=$wb_dejagnu/host/src/$gnu
    dj_gnu=$root_working_dir/gnu
    tool_dirs="$testsuite_dir/tests $testsuite_dir/testsuite"
    need_dirs="dejagnu tcl $tool_dirs"
    verbose "Copying dejagnu framework into workspace ..."
    dirs_not_refreshed=
    for dir in $need_dirs; do
# True if one $dir matches one of the prefixes specified by
# the user in $update_list
	force_update=
	get_update_list
	if [ -n "$update_list" ]; then
	    if [ -n "`echo $dir | egrep $update_list`" ]; then
		force_update=t
	    fi
	fi
	if [ ! -f $dj_gnu/$dir/stamp -o -n "$force_update" ]; then
	    verbose "- $dj_gnu_orig/$dir to $dj_gnu/$dir ... "
	    if [ -d $dj_gnu/$dir ]; then
		rm -rf $dj_gnu/$dir
	    fi
	    mkdir -p $dj_gnu/$dir
	    cp -rf $dj_gnu_orig/$dir/* $dj_gnu/$dir
	    touch $dj_gnu/$dir/stamp
	else
	    dirs_not_refreshed=t
	    verbose  "-   $dj_gnu/$dir [not refreshed]"
	fi
    done
    if [ -n "$dirs_not_refreshed" ]; then
	verbose "Some directories were not refreshed. To refresh a"
	verbose "particular directory either delete the cache stamp"
	verbose "(for example to refresh dejagnu, delete"
	verbose "$dj_gnu/dejagnu/stamp) or use the -update option."
    fi
    event "dj_gnu=$dj_gnu"
}

# True if update_list delimeter been converted from space to |
update_list_converted=

get_update_list ()
{
    event "get_update_list"
    if [ -n "$update_list_converted" ]; then return; fi
    update_list=${update_list// /|}
    event "update_list=$update_list"
}

get_EXPECT ()
{
    event "get_EXPECT"
    if [ -n "$EXPECT" ]; then return; fi
    get_local_host
    get_dj_gnu
# The original expect
    EXPECT_orig=$wb_dejagnu/host/$local_host/bin/expect
    bin_dir=$dj_gnu/$local_host/bin
    mkdir -p $bin_dir
    EXPECT=$bin_dir/expect
    verbose "Copying expect from $EXPECT_orig to $EXPECT"
    cp -f $EXPECT_orig $EXPECT
    event "EXPECT=$EXPECT"
}

# This is either gnu (if $wb_dejagnu points to a tree with only one
# host/src/gnu directory) or gnu.cpp (otherwise). Don't worry about it!
gnu=

get_gnu ()
{
    event "get_gnu"
    if [ -d $wb_dejagnu/host/src/gnu.cpp ]; then
	gnu=gnu.cpp
    else
	gnu=gnu
    fi
    event "gnu=$gnu"
}

get_windsh_script ()
{
    event "get_windsh_script"
    if [ -n "$windsh_script" ];then return; fi
    get_dj_gnu
    windsh_script=$dj_gnu/dejagnu/windsh.tcl
    event "windsh_script=$windsh_script"
}

# True if $wb_tgtsvr has been formatted to only contain forward slashes
wb_tgtsvr_slashified=

get_wb_tgtsvr ()
{
    event "get_wb_tgtsvr"
    if [ -n "$wb_tgtsvr_slashified" ]; then return; fi
    wb_tgtsvr=`slashify $wb_tgtsvr`
    wb_tgtsvr_slashified=t
    event "wb_tgtsvr=$wb_tgtsvr"
}

get_wb_tgtsvr_as_seen_from_unix ()
{
    get_arch
    if [ $cpu = SIMNT ]; then
	wb_tgtsvr_as_seen_from_unix=$wb_virtual_tgtsvr
    else
	wb_tgtsvr_as_seen_from_unix=$wb_tgtsvr
    fi
}

get_wb_framework ()
{
    event "get_wb_framework"
# NT versions will also be needing the right wind base in order for the correct
# creation of the -I command line option for nt (see gcc/testfiles/lib/g++.exp)
#    if [ -z "$testing_windows" ]; then
	wb_framework=$wb_test
#    else
#	wb_framework=$wb_virtual_test
#    fi
    event "wb_framework=$wb_framework"
}

get_unix_home_and_windows_home ()
{
    event "get_unix_home_and_windows_home"
    if [ -z "$unix_home" ]; then
	unix_home=`echo $unix_to_windows_map | cut -f1 -d=`
	windows_home=`echo $unix_to_windows_map | cut -f2 -d=`
    fi
    event "unix_home=$unix_home"
    event "windows_home=$windows_home"
}

# These ones depend on the context and are recalculated each time
# They only need to be called when we change directories. In practice
# we do a little work in $root_working_dir and then
# then rest in $actual_working_dir.

get_cwd_as_seen_from_unix ()
{
    event "get_cwd_as_seen_from_unix"
    cwd_as_seen_from_unix=`pwd`
    event "cwd_as_seen_from_unix=$cwd_as_seen_from_unix"
}

# If $testing_windows then call this one to get both views of cwd.
get_cwds_for_unix_and_windows ()
{
    event "get_cwds_for_unix_and_windows"
# The two views of cwds should always refer to the same directory
    get_cwd_as_seen_from_unix
    cwd_as_seen_from_windows=`unix_to_windows $cwd_as_seen_from_unix`
    event "cwd_as_seen_from_windows=$cwd_as_seen_from_windows"
}

get_run_bat ()
{
    event "get_run_bat"
    run_bat=$cwd_as_seen_from_unix/run.bat
    if [ ! -r "$run_bat" -o $start_stamp -nt "$run_bat" ]; then
	event "Regenerating $run_bat"
	event "windows_home=$windows_home"
	cat > $run_bat <<EOF
@echo off
set WIND_REGISTRY=$WIND_REGISTRY
set WIND_BASE=`backslashify $wb_test`
set WIND_HOST_TYPE=x86-win32
set PATH=`backslashify $wb_test`\\host\\x86-win32\\bin;%PATH%
$windows_home
cd $cwd_as_seen_from_windows
%*%
EOF
    fi
    chmod u+x $run_bat
    event "run_bat=$run_bat"
}

get_event_log ()
{
    if [ -z "$event_log" ]; then
#	event_log=$home_dir/events.`date +%d%h-%T`
	event_log=$home_dir/events
	rm -f $event_log
	touch $event_log
	xterm -sb -fg black  -bg salmon -title \
              "$program event log : $event_log" -e tail -f $event_log &
	echo "** Events being logged to $event_log **"
	event "get_event_log"
    fi
}

get_windows_log ()
{
    event "get_windows_log"
    windows_log=$cwd_as_seen_from_unix/x86-win32.log
    if [ -r $windows_log -a $start_stamp -nt $windows_log ]; then
	rm -f $windows_log
    fi
    event "windows_log=$windows_log"
}

#####################################################################
# late sanity check
#
# The command parsing stage does sanity checking and
# default value generation. Some checks can only
# be done after we have discovered derived values
# like *arch*.  Each function here should be named
# after_get_xxx and should be called at the end
# of get_xxx. If a function finds something wrong
# it *must* abort by calling exit_nicely. It should
# not attempt to correct the problem because it
# may already be too late.


after_get_arch ()
{
    event "after_get_arch"
# Our defaults are nice in most cases but probably won't
# work for ARM or SIMPC
# ARM
    if [ -n $wb_windsh_default_for_arm ]; then
	if [ $arch = arm ]; then
	    if [ $wb_windsh = $wb_windsh_default ]; then
		$CAT <<EOF
I don't thing that the default value for WIND_BASE for the
Wind Shell  ($wb_windsh_default
works for ARM targets. Try -windsh $wb_windsh_default_for_arm
instead.
EOF
		quit=t
	    fi
# Recall that there is no wb_tgtsvr_default; it defaults
# to $wb_windsh.
	    if [ $wb_tgtsvr = $wb_windsh_default ]; then
		$CAT <<EOF
I don't thing that the default value for WIND_BASE for the
Target Server ($wb_windsh_default
works for ARM targets. Try -tgtsvr $wb_windsh_default_for_arm
instead.
EOF
		quit=t
	    fi
	 fi
    fi
# SIMPC
# The SIMPC target server must be a windows executable visible
# from windows.
    if [ $cpu = SIMNT ]; then
	if [ $wb_tgtsvr = $wb_windsh ]; then
	    $CAT <<EOF
I don't think the default value for WIND_BASE for the Target
Server ($wb_windsh) is going to work for the PC Simulator.
You need to point to a windows executable visible on $windows_host.
Perhaps your test tree contains Target Server executables? In that
case why not try -tgtsvr $wb_test.
EOF
	quit=t
	fi
    fi
    if [ -n "$quit" ]; then
	exit_nicely
    fi
}

after_get_kernel ()
{
    event "after_get_kernel"
    if [ ! -r "$kernel" ]; then
	get_bsp_dir
#	kernel_orig=$wb_kernel/$bsp_dir/vxWorks
	kernel_orig=$wb_kernel/$bsp_dir/${cpu}gnu.debug/boot.txt
	if [ -n "$testing_windows" ]; then
	    kernel_orig=`echo $kernel_orig | sed 's@/@\\@g'`
	fi
	echo "I didn't manage to find the kernel ($kernel_orig), try using -build."
	exit_nicely
    fi
}

#####################################################################
# gen functions
#
# These put things into the workspace (actually the current
# working directory which is usually $root_working_dir or
# $actual_working_dir). Some of them are executables, copied
# out of $wb_test. Others are wrapper scripts or files
# needed by dejagnu.
#
# A few things that are generated must be cleaned up.
# This can all be done in one step by calling cleanup.


# Certain startup parameters are specified by the user's
# .dejagnurc file.


# Location of .dejagnurc file
dejagnurc=
# True if the user already had a .dejagnurc.
need_to_restore_dejagnurc=
# Location of a backed up copy of the user's .dejagnurc.
dejagnurc_bak=

gen_dejagnurc ()
{
    event "gen_dejagnurc"
    dejagnurc=$HOME/.dejagnurc
    if [ -f "$dejagnurc" ]; then
# Backup the existing one
	need_to_restore_dejagnurc=t
	dejagnurc_bak=${dejagnurc}.bak
	i=0
# Come up with an unused name
	while [ -f "$dejagnurc_bak" ]; do
	    i=`expr $i + 1`
	    dejagnurc_bak=${dejagnurc}.$i
	done
	verbose "Backing up your existing $dejagnurc to $dejagnurc_bak"
	mv $dejagnurc $dejagnurc_bak
    fi
    verbose "Writing $dejagnurc"
    get_wb_framework
    get_kernel
    get_windsh_script
    DJ_VXWORKS_HOMEDIR=$cwd_as_seen_from_unix/tmp
    rm -rf $DJ_VXWORKS_HOMEDIR
    cat > $dejagnurc <<EOF
# This was automatically generated by $program
set WIND_BASE $wb_framework
set DJ_KERNEL $kernel
set DJ_VXWORKS_HOMEDIR $DJ_VXWORKS_HOMEDIR
set use_existing_path t
set windsh_script $windsh_script
EOF
}

# Each tool/arch maps to a particular site.exp file.
gen_site_exp ()
{
    event "gen_site_exp"
    case $tool in
	gcc ) gen_gcc_site_exp ;;
	g++ ) gen_gxx_site_exp ;;
	libio|libstdc++ ) gen_library_site_exp ;;
    esac
}

#####################################################################
# functions to generate tool specific site.exp files
#

gen_gcc_site_exp ()
{
    event "gen_gcc_site_exp"
    get_host_triplet
    get_target_triplet
    get_dj_gnu
    get_testsuite_dir
# We make two passes: a `normal' one and an optimized one
#    case $target_triplet in
#	i960* ) MULTIPASS='"{ -O TOOL_OPTIONS=-O } { \"\" }"' ;;
#	* ) MULTIPASS='"{ -O2 TOOL_OPTIONS=-O2 } { \"\" }"' ;;
#    esac
    tmpdir=$cwd_as_seen_from_unix/tmpdir
    mkdir -p $tmpdir
    cat > site.exp <<EOF
set rootme $cwd_as_seen_from_unix
set srcdir $dj_gnu/$testsuite_dir/testsuite
set host_triplet $host_triplet
set build_triplet $host_triplet
set target_triplet $target_triplet
set target_alias $target_triplet
#set CFLAGS ""
#set CXXFLAGS ""
#set newlib_cflags ""
#set newlib_ldflags ""
set tmpdir $tmpdir
#set MULTIPASS $MULTIPASS
EOF
}

gen_gxx_site_exp ()
{
    event "gen_gxx_site_exp"
    get_host_triplet
    get_target_triplet
    get_dj_gnu
    get_testsuite_dir
# We make two passes: a `normal' one and an optimized one
    case $target_triplet in
	i960* ) MULTIPASS='"{ -O TOOL_OPTIONS=-O } { \"\" }"' ;;
	* ) MULTIPASS='"{ -O2 TOOL_OPTIONS=-O2 } { \"\" }"' ;;
    esac
    tmpdir=$cwd_as_seen_from_unix/tmpdir
    mkdir -p $tmpdir
    cat > site.exp <<EOF
set rootme $cwd_as_seen_from_unix
set srcdir $dj_gnu/$testsuite_dir/testsuite
set host_triplet $host_triplet
set build_triplet $host_triplet
set target_triplet $target_triplet
set target_alias $target_triplet
#set CFLAGS ""
#set CXXFLAGS ""
#set newlib_cflags ""
#set newlib_ldflags ""
set tmpdir $tmpdir
set MULTIPASS $MULTIPASS
EOF
}

gen_library_site_exp ()
{
    event "gen_library_site_exp"
# Yes, we really do mean to set host_triplet to $target_triplet!
    get_target_triplet
    get_dj_gnu
    get_testsuite_dir
# We make two passes: a `normal' one and an optimized one
    case $target_triplet in
	i960* ) MULTIPASS='"{ -O TOOL_OPTIONS=-O } { \"\" }"' ;;
	* ) MULTIPASS='"{ -O2 TOOL_OPTIONS=-O2 } { \"\" }"' ;;
    esac
    cat > site.exp <<EOF
set host_alias $target_triplet
set host_triplet $target_triplet
set target_alias $target_triplet
set target_triplet $target_triplet
set build_triplet $target_triplet
set srcdir $dj_gnu/$testsuite_dir/testsuite
set tool $tool
set MULTIPASS $MULTIPASS
EOF
    if [ $tool = libio ]; then
    cat > Makefile <<EOF
# libio tests want a file called "Makefile". It has
# to begin with two comment lines ...
EOF
    fi
}


# The dejagnu framework wants to invoke things like
# xgcc, ld-new and munch. The correct executables are
# the ones in $wb_test. We place copies or wrapper
# scripts in our workspace.
gen_toolchain ()
{
    event "gen_toolchain"
    get_wb_framework
    get_target_triplet
# Location of driver binaries such as cc$arch, ld$arch.
    bin_base=$wb_framework/host/$WIND_HOST_TYPE/bin
    target_base=$bin_base/../lib/gcc-lib/$target_triplet
    gcc_ver=`remote_ls $target_base`
    event "gcc_ver=$gcc_ver"
# Location of the `core' tools
    tool_base=$target_base/$gcc_ver
    event "tool_base=$tool_base"
# These are tools that are needed by the drivers.
    remote_copy_exec $tool_base/cc1 .
    remote_copy_exec $tool_base/cc1plus .
    remote_copy_exec $tool_base/cpp .
# FIXME: This is a little peculiar
    if [ -n "$testing_windows" ]; then
	remote_copy_exec $tool_base/collect2 .
	remote_copy_exec $bin_base/../$target_triplet/bin/ld .
    else
        if [ $arch = hppa ]; then
            remote_copy_exec /bin/ld .
            remote_copy_exec /bin/ld $target_triplet-ld
        else
	    remote_copy_exec $tool_base/collect2 .
	    remote_copy_exec $bin_base/../$target_triplet/bin/ld .
	fi
    fi
    remote_copy_exec $bin_base/../$target_triplet/bin/as .

# These are drivers (or self-contained programs) that are
# invoked by the framework.
    wrap_gnu_tool $bin_base/cc$arch xgcc
    wrap_gnu_tool $bin_base/ld$arch ld-new
    wrap_gnu_tool $bin_base/nm$arch nm-new
    wrap_gnu_tool $bin_base/objdump$arch objdump
    wrap_tornado_tool $bin_base/munch munch
    wrap_tornado_tool $bin_base/vxsim vxsim
    wrap_tornado_tool $bin_base/wtxregd wtxregd
}

# The framework also needs Tornado tools like
# wtxtcl, windsh and tgtsvr. The correct executables are
# the ones in $wb_windsh (wtxtcl and windsh - run on LOCAL)
# and $wb_tgtsvr (tgtsvr - runs on (arch=simpc) ? LOCAL : REMOTE). We put
# appropriately named wrappers in our workspace.
gen_tornado_tools ()
{
    event "gen_tornado_tools"
    get_wb_framework

    get_local_host
    windsh_bin_base=$wb_windsh/host/$local_host/bin
    wrap_tornado_tool -local $windsh_bin_base/wtxtcl wtxtcl
# TODO add -Tclmode -noinit -startup $windsh_script
    wrap_tornado_tool -local $windsh_bin_base/windsh windsh
    get_wb_tgtsvr_as_seen_from_unix
    get_arch
    if [ $cpu = SIMNT ]; then
	get_WIND_HOST_TYPE
	tgtsvr_bin_base=$wb_tgtsvr_as_seen_from_unix/host/$WIND_HOST_TYPE/bin
	wrap_tornado_tool $tgtsvr_bin_base/tgtsvr tgtsvr
    else
	tgtsvr_bin_base=$wb_tgtsvr_as_seen_from_unix/host/$local_host/bin
	wrap_tornado_tool -local $tgtsvr_bin_base/tgtsvr tgtsvr
    fi

}

#
# Start a wtxregd on the local host if -registry was not specified
#

start_wtxregd ()
{
    if [ -z "$setting_registry" ]; then
	event "start_wtxregd"
	if [ -n "$testing_windows" ]; then
	    ./wtxregd &
	else
#	    get_WIND_HOST_TYPE
# Assume for now the solaris registry is good for everything in T3.
	    WIND_HOST_TYPE=$local_host
	    export WIND_HOST_TYPE
	    PATH=$wb_tgtsvr/host/$wh_type/bin:$PATH WIND_BASE=$wb_tgtsvr $wb_tgtsvr/host/$wh_type/bin/wtxregd start
	fi
    fi
}



# This routine attempts to rebuild a VxWorks kernel in $wb_kernel.
# It uses a scrit called buildT3sys located in the working directory that
# get generated by rundeja under  $root_working_dir/gnu/dejagnu/buildT3sys
# This script takes two arguments  bsp and cpu types.
### PLEASE NOTE THAT THIS WAY OF GENERATING KERNELS IS A T3 ONLY THING

gen_kernel ()
{
    event "gen_kernel"
    get_bsp_dir
    get_WIND_HOST_TYPE

    cpu=`sed -n "s@.*CPU.*= *\([A-Z0-9]*\).*@\1@p" $wb_kernel/target/config/$bsp/Makefile`
    PROJ_BASE=${wb_kernel}/target/proj
    $root_working_dir/gnu/dejagnu/buildT3sys ${bsp} ${cpu}
}


# Call this at the end
cleanup ()
{
    event "cleanup"
    if [ -n "$need_to_restore_dejagnurc" ]; then
	verbose "Restoring your backed up .dejagnurc"
	mv $dejagnurc_bak $dejagnurc
    fi
}


#####################################################################
# Functions that convert from unix land to windows land
#
# The functions should only be called if $testing_windows

# One backslash for the price of two (!)
bslash='\\'

# Converts a filename or command that contains filenames as
# seen from LOCAL (unix) and convert to filenames as
# seen by REMOTE (windows). The resulting filenames
# use double back slashes since typically one is
# eaten by the shell.
unix_to_windows ()
{
    event "unix_to_windows $*"
# First we create a forward slash version by substituting
# $wb_test for $wb_virtual_test and $windows_home for $unix_home.
# Then we turn forward slashes into backslashes.

    fw_slash=`echo "$*" | sed "\
s@${wb_virtual_test}@${wb_test}@g;\
s@${unix_home}@${windows_home}@g;\
s@${wb_virtual_tgtsvr}@${wb_tgtsvr}@g"`
    backslashify $fw_slash | sed 's@ -\(.\) @ /\1 @g'
}

# Converts (sequences of) backslashes into forward slashes
slashify ()
{
    event "slashify $*"
    echo "$*" | sed "s@${bslash}${bslash}*@/@g"
}

# Converts a forward slashes into backslashes
backslashify ()
{
    event "backslashify $*"
    echo "$*" | sed "s@/@${bslash}@g"
}

# Carriage return
CR=`echo x | tr x "\015"`

# Use this filter to remove carriage returns
filter_out_CR="sed 's@$CR\$@@g'"

#####################################################################
# Functions that execute commands on REMOTE
#

# Converts file names from unix to windows and executes
# the command on windows with the current working
# directory set to $cwd_as_seen_from_windows
windows_exec ()
{
    event "windows_exec $*"
    get_run_bat
    command="`unix_to_windows $run_bat $*`"
    event rsh $windows_host -n $command
    rsh $windows_host -n $command
}


#####################################################################
# remote_copy <src> <dest>
#
# Converts file names from LOCAL to REMOTE and executes
# a copy of <src> to <dest> on REMOTE.
# The resulting file has rw permissions.

remote_copy ()
{
    event "remote_copy $*"
    if [ -n "$testing_windows" ]; then
	windows_exec copy $1 $2
    else
	cp -rf $1 $2
    fi
    chmod -R u+w $2
}

#####################################################################
# remote_copy_exec <src> <dest>
#
# Converts file names from LOCAL to REMOTE and executes
# a copy of the executables with basename <src> to <dest>.
# In the windows case we try <src>.* instead of <src>.
# Unless <dest> is `.' the extension will not be preserved.
# The resulting file has rwx permissions.
# No error will be generated if the copy fails.

remote_copy_exec ()
{
    event "remote_copy_exec $*"
    if [ -n "$testing_windows" ]; then
	windows_exec copy $1.* $2
    else
	cp -f $1 $2
    fi
    chmod u+wx $2
}

#####################################################################
# remote_ls <dir>
#
# Return a bare directory listing for directory <dir> on remote.
remote_ls ()
{
    event "remote_ls $*"
    if [ -n "$testing_windows" ]; then
	eval "windows_exec dir -b $1 | $filter_out_CR"
    else
	ls $1
    fi
}

#####################################################################
# Functions that write script fragments
#

# Writes a script fragment to stdout that runs the given
# program on windows *with any additional args passed to
# the script*. The program starts with the current working
# directory set to $cwd_as_seen_from_windows. The program
# name (and any constant args) should use
# absolute unix pathnames.
write_windows_exec ()
{
    event "write_windows_exec $*"
    get_run_bat
# This is a fragment that gets inserted into the script
# to convert the command line args passed to the script
# from unix path names to windows path names. Note that
# all the variables mentioned are expanded here and
# represent constants in the script - except for
# \$* which is a literal and gets output as is.
    get_unix_home_and_windows_home
# This is the actual command that gets run on windows
    command="\`echo $run_bat $* \$* | sed '\
s@${wb_virtual_test}@${wb_test}@g;\
s@${unix_home}@${windows_home}@g;\
s@/@${bslash}${bslash}@g'\`"
    echo "command=$command"
    if [ -n "$verbose_flag" ]; then
	get_windows_log
	echo "echo \$command >> $windows_log"
    fi
    echo "rsh $windows_host -n \$command"
}

# write_windows_env <WIND_BASE>
#
# Write a script fragment that sets up the environment for
# tornado tools running on windows. WIND_BASE must
# be a windows path starting with <drive>:

write_windows_env ()
{
    event "write_windows_env $*"
    wb=$1
    drive=`echo $wb | cut -f1 -d:`
    echo "set WIND_REGISTRY=$WIND_REGISTRY"
    echo "set WIND_BASE=$wb"
    echo "set WIND_HOST_TYPE=x86-win32"
    echo "set PATH=$wb\\host\\x86-win32\\bin;%PATH%"
    echo "${drive}:"
}

# write_unix_env <WIND_BASE> <WIND_HOST_TYPE>
#
# Write a (beginning) script fragment that sets up the environment for
# tornado tools.

write_unix_env ()
{
    event "write_unix_env $*"
    wb=$1
    wh_type=$2
# On Solaris we need to set LD_LIBRARY_PATH
    set_ld_library_path=
    case $local_host in
	*solaris* )	set_ld_library_path="\
LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$wb/host/$wh_type/lib; \
export LD_LIBRARY_PATH"
    esac
    echo "#!/bin/sh"
    echo "WIND_REGISTRY=$WIND_REGISTRY"
    echo "export WIND_REGISTRY"
    echo "WIND_BASE=$wb"
    echo "export WIND_BASE"
    echo "WIND_HOST_TYPE=$wh_type"
    echo "export WIND_HOST_TYPE"
    echo "PATH=$wb/host/$wh_type/bin:\$PATH"
    echo "export PATH"
    echo "$set_ld_library_path"
}

#####################################################################
# Wrapping functions
#

#####################################################################
# wrap_tornado_tool [-local] <the_tool> <unix_script>
#
# Write a script called <unix_script> that can be called from
# the test framework to invoke the tornado tool <the_tool> with
# the environment set up appropriately.
# The -local option specifies that <the_tool> will run on LOCAL.
# Otherwise it will run on REMOTE. Notice that in either
# case <the_tool> is an as-seen-from-unix path.
wrap_tornado_tool ()
{
    event "wrap_tornado_tool $*"
# True if this tool with run on LOCAL (unix)
    local=
    while [ -n "`echo $1 | grep '^-'`" ]; do
	case $1 in
	    -local ) local=t ;;
	esac
	shift
    done
    the_tool=$1
    unix_script=$2
    event "the_tool=$the_tool"
    event "unix_script=$unix_script"
# Tornado tools need WIND_BASE to be set. Derive the appropriate
# WIND_BASE by assuming that the location of the tool is
# $WIND_BASE/host/$WIND_HOST_TYPE/bin.
# This is WIND_BASE as seen from unix.
    WIND_BASE_unix=`echo $the_tool | sed "s@/host/.*/bin/.*@@"`
# This is the path to the tool as seen from unix.
    if [ -n "$local" ]; then
	the_host=$local_host
    else
	the_host=$WIND_HOST_TYPE
    fi
# Empty unless $instrument in which case the code to log an event
    event_fragment=
    if [ -n "$instrument" ]; then
	event_fragment="echo \"$unix_script \$*\" >> $event_log"
    fi
    if [ -z "$testing_windows" -o -n "$local" ]; then
	write_unix_env "$WIND_BASE_unix" "$the_host" > $unix_script
	cat >> $unix_script <<EOF
$event_fragment
$the_tool \$*
EOF
    else
# Windows
	windows_script=w${unix_script}.bat
	write_windows_env "`unix_to_windows $WIND_BASE_unix`" > $windows_script
	cat >> $windows_script <<EOF
`unix_to_windows $the_tool` %*%
EOF
	cat > $unix_script <<EOF
#!/bin/sh
$event_fragment
EOF
	write_windows_exec $windows_script >> $unix_script
    fi
    chmod u+x $unix_script
}

#####################################################################
# wrap_gnu_tool <the_tool> <unix_program>
#
wrap_gnu_tool ()
{
    event "wrap_gnu_tool $*"
    the_tool=$1
    unix_program=$2
    if [ -z "$testing_windows" ]; then
# Unix
	cp -f $the_tool $unix_program
    else
# Windows
	windows_program=`echo $the_tool | sed 's@^.*/\([^/]*\)$@\1@'`.exe
	remote_copy_exec $the_tool .
	echo "#!/bin/sh" > $unix_program
        rewrite=s,q,q,
	    ### Commenting the next 3 lines of code. Not sure what they
	    ### do, since they seem to have been put in by Mike for some
	    ### hpux libio testing, they are messing up C++ testing under
	    ### NT.  Samuel
       # if [ "$unix_program" = xgcc ]; then
       #    rewrite='s,command$,{command}.,'
       # fi

	write_windows_exec $windows_program | sed $rewrite >> $unix_program
    fi
    chmod u+x $unix_program
}

#####################################################################
# Miscellaneous
#

# assert <command> <string>
# If <string> is empty then execute <command> and set quit=t.

assert ()
{
    if [ -z "$2" ]; then
	eval $1
	quit=t
    fi
}

# Be chatty if $verbose_flag
verbose ()
{
    event "verbose $*"
    if [ -n "$verbose_flag" ]; then
	echo "$*" 1>&2
    fi
}

# Log if $instrument
event ()
{
    if [ -n "$instrument" ]; then
	get_event_log
	echo $* >> $event_log
#	echo "EVENT: $*" 1>&2
    fi
}

# To be called after a fatal error.
exit_nicely ()
{
    event "exit_nicely"
    echo "To learn more try $0 --help."
    exit 1
}

# To be called after a successful test run
exit_happily ()
{
    cleanup
    echo ""
    echo "------------------------------------------------------------------"
    echo "The results are in $actual_working_dir"
    echo "in the files ${tool}.sum and ${tool}.log."
    if [ -n "$debug_flag" ]; then
	echo "A dejagnu debug log has been written to dbg.log"
    fi
    if [ -n "$instrument" ]; then
	echo "Events have been logged to $event_log"
    fi
    if [ -n "$windows_log" ]; then
	echo "Windows commands have been logged to $windows_log"
    fi
    echo ""
    echo "If something unexpected happened during this run you may want to try"
    echo "$program -hints troubleshooting"
    echo "or reinvoking with -verbose or (for debugging this script)"
    echo "-instrument."
}

# This is a safe cd. The directory need not exist beforehand.
#
# You may assume that cwd_as_seen_from_unix and (if appropriate)
# cwd_as_seen_from_windows are valid afterwards.
# Always use this instead of cd.

change_dir ()
{
    event "change_dir $*"
    mkdir -p $1
    cd $1
    if [ -z "$testing_windows" ]; then
	get_cwd_as_seen_from_unix
    else
	get_cwds_for_unix_and_windows
    fi
}

######################################################################
# Help
#

# Print usage for a particular option.
# If no option is specified print general usage info.
usage ()
{
    event "usage $*"
     case $1 in
	board )
# -board
	    $CAT <<EOF
You must specify the name of a target board using -board. For
example t22-174. There are simulator targets and embedded
targets. In the former case you may choose from:

simsolaris
simhppa
simpc

In the embedded case, make sure that
(1) The board has an X10 controller ID
(2) There is an entry in your .rhosts file for the board
Configuration (.exp) files already exist for many boards.
If you are not using a Test Lab board you will need to
provide an X10 id (-x10), the bsp name (-bsp) and a set
of compiler flags (-cflags).
EOF
	    ;;
	tool )
# -tool
	    $CAT <<EOF
You must specify the name of a tool to test using -tool.
Currently available tools are:
gcc
g++
libio
libstdc++
EOF
	    ;;
	x10 )
# -x10
	    $CAT <<EOF
You may need to specify an X10 controller ID using -x10.
EOF
	    ;;
	bsp )
# -bsp
	    $CAT <<EOF
You may need to specify the name of a bsp (for example mv1603)
using -bsp.
EOF
	    ;;
	cflags )
# -cpu
	    $CAT <<EOF
You may need to specify the CPU for a kernel with -cpu.
This is usually the definition of CPU in the Kernel's Makefile
(for example PENTIUM2, PPC604 etc).
EOF
	    ;;
	cflags )
# -cflags
	    $CAT <<EOF
You may need to specify an cpu specific set of cflags (for example
 " -mstrict-align -DCPU=PPC603 -DMV1600 ") using -cflags.
EOF
	    ;;
	ignore-rhosts )
# -ignore-rhosts
	    $CAT <<EOF
The target board grabs the kernel from your unix machine via rsh.
We normally check whether your .rhosts file contains an
entry for the target board. If for some reason you
want to turn off this check then specify -ignore-rhosts.
EOF
	    ;;
	root )
# -root
	    $CAT <<EOF
You may specify a directory (using -root) that we can use for caching
data, placing proxy executables and stashing test results. This
should always be a path on your unix machine. Experience
has shown that paths of the form /net/<machine>/<machine>n/... cause
problems. Use /<machine>n/... instead. Ideally just use the form
/folk/<user>/... .
The default is $root_working_dir_default. The
test results are placed in a subdirectory
<WIND_HOST_TYPE>/<tool>/<arch>/<board>
(for example sun4-solaris2/libio/ppc/t22-174).
EOF
	    ;;
	test )
# -test
	    $CAT <<EOF
You must specify WIND_BASE for the tree you want to test using
-test.
This should be a unix path for unix executables and a windows path
for windows executables. Windows paths should always be of the
form <drive-letter>:/.../... . You may optionally use backslashes.
EOF
	    ;;
	kernel )
# -kernel
	    $CAT <<EOF
You may specify WIND_BASE for the tree containing the VxWorks
kernel using -kernel. This defaults to <wb_test>.
If the test host is unix then this must be a unix path.
However, unlike most parameters, if the test host is windows
you may choose to get the kernel from either windows or from
unix.
I will assume that paths starting with <drive>: are windowsy
and that all other paths are unixy. You may use either
forward slashes or backslashes.
Kernels should be built with the following line
make vxWorks "ADDED_CFLAGS=-DINCLUDE_CPLUS_IOSTREAMS_FULL -DINCLUDE_CPLUS_STRING_IO -DINCLUDE_CPLUS_COMPLEX_IO -DINCLUDE_CPLUS_IOSTREAMS_TEST"
Use the -build option if you want me to rebuild a kernel.
EOF
	    ;;
	build )
# -build
	    $CAT <<EOF
You may ask me to build a kernel in <wb_kernel> using -build. This requires
that there are compiler and tornado executables present in
the <wb_kernel> tree. Every time you use this option I
will do a make clean followed by a make release with the
appropriate defines. So if you are doing multiple tests
on the same bsp you probably don't want to specify -build
every time.
EOF
	    ;;
	dejagnu )
# -dejagnu
	    $CAT <<EOF
You may specify WIND_BASE for the tree containing the dejagnu test
framework and an "expect" binary using -dejagnu.
The default is $wb_dejagnu_default.
EOF
	    ;;
	tgtsvr )
# -tgtsvr
	    $CAT <<EOF
You may specify WIND_BASE for the tree containing the Target Server
using -tgtsvr.
If you are testing the PC Simulator then this
should be a windows path to a windows executable.
Otherwise it should be a unix path to a unix executable. In
the latter case the default is <wb_windsh>.
EOF
	    ;;
	update )
# -update
	    $CAT <<EOF
We normally cache a set of dejagnu related gnu directories in our
workspace. Originally they came from <wb_dejagnu> (try
$program -usage dejagnu for more info). While debugging the
framework itself you may want to force updates of certain subdirectories.
Use the -update flag to specify a list of directory prefixes.
Any subdirectory with a matching prefix will be updated.
For example in libio testing, -update "dejagnu libio"
will update the directories dejagnu, libio/tests and libio/testsuite
(as well as all their subdirectories).
EOF
	    ;;
	windsh )
# -windsh
	    $CAT <<EOF
You may specify WIND_BASE for the tree containing a Wind Shell
using -windsh.
This should always be a unix path to a unix executable. The
default is $wb_windsh_default.
EOF
	    ;;
	host )
# -host
	    $CAT <<EOF
For testing on windows you must specify a windows host (!) using
-host.
EOF
	    ;;
	map )
# -map
	    $CAT <<EOF
For testing on windows you must specify a unix to windows map
(using -map) that makes the root working directory specified
with -root visible on the windows host. As a preliminary
step you need to run the "net use" command on your windows machine.
Do this directly, not via rsh!
For example suppose <root_working_dir> is /folk/<user>/dejaroot.
Suppose the equivalent network path is
/net/<machine>/<machine>1/<user>/dejaroot.
Then run the following command on windows:

net use Z: \\\\<machine>\\<machine>1\\<user>

and invoke $program with

-map /folk/<user>=Z:
EOF
	;;
	registry )
# -registry
	$CAT <<EOF
-registry allows you to set WIND_REGISTRY. The default is $WIND_REGISTRY_default.
Good choices are mustaine, hera or queen. This program will make make no attempt
to start its own wtdregd if you use the -registry option.
EOF
	;;
	verbose )
# -verbose
    	$CAT <<EOF
-verbose makes this script print some useful information as it works.
EOF
	;;

	debug )
# -debug
	$CAT <<EOF
-debug makes the framework generate a dbg.log file.
EOF
	;;
	talkative )
# -talkative
	$CAT <<EOF
-talkative makes the framework print lots of information as it works.
EOF
	;;
	other )
# -other
	$CAT <<EOF
You may specify other flags to pass to "runtest" using -other.
EOF
	;;
	usage )
# -usage
	$CAT <<EOF
For help on an option type
$program -usage <option>
EOF
	;;
	* )
# Default
	    $CAT <<EOF
$program : Usage $program -board <board> -tool <tool>
		     [-x10 <X10_ID> -bsp <bsp> -cflags <cflags>]
		     [-ignore-rhosts]
		     [-root <root_working_dir>] [-test <wb_test>]
		     [-cpu <CPU>]
		     [-kernel <wb_kernel>] [-build]
		     [-dejagnu <wb_dejagnu>] [-tgtsvr <wb_tgtsvr>]
		     [-update <update_list>]
		     [-windsh <wb_windsh>]
		     [-host <windows_host> -map <unix_home>=<drive_letter>:]
		     [-registry <WIND_REGISTRY>]
		     [-verbose] [-debug] [-talkative]
		     [-other <other_flags>]
	 	     [-usage <option>]
		     [-hints <topic>]

For help on a particular option type:
$program -usage <option>

For hints on getting started on getting started try
$program -hints
EOF
	    ;;
    esac
    echo ""
}

hints ()
{
    case $1 in
	unix )
# unix
	    $CAT <<EOF
Here are some hints for getting started with unix testing:

(1) Choose a target board (for example t22-174). Try
    $program -usage board
    for more information.
(2) Make sure there is an entry for this board in your
    .rhosts file.
(3) Choose a test tree. This may be in clearcase or it
    may be an installed image. Let <test> be WIND_BASE
    for this tree.
(4) If the test tree is not readonly you can ask $program
    to build a VxWorks image using -build. Otherwise
    you'll need to build one yourself. Try
    $program -usage kernel
    for more information.
(5) Choose one of these tools: libio, libstdc++, gcc, g++.

Type

rundeja -board <board> -tool <tool> -test <test> [-build] -verbose

(-verbose is optional but strongly recommended the first few
times you use $program).
EOF
	    ;;
	windows )
# windows
	    $CAT <<EOF
Here are some hints for getting started with windows testing

(1)  Find a windows host (<host>)
(2)  Install an rsh server on <host>. We tested $program with
     the "ataman" rsh daemon. To learn more about this, try
     $program -hints ataman.
(3)  On windows host, set clearcase option to disable
     disconnect on new login.
     * Start->Settings->Control Panel->ClearCase Properties
         ->MVFS(tab)
     * At "Action to take when a new user logs on:" select
         None
(4)  Find a unix host (this machine).
(5)  Set up a unix to windows map. For more information try
     $program -usage map.
(6)  Choose a target board (for example t22-174). Try
     $program -usage board
     for more information.
(7)  Make sure there is an entry for this board in your
     .rhosts file (on the unix machine).
(8)  Choose a test tree. This must be (visible on) <host>
     and must contain windows executables. Let <test> be WIND_BASE
     for this tree. It should be of the form
     <drive>:/.../... . You may optionally use
     backslashes.
(9)  If the test tree is not readonly you can ask $program
     to build a VxWorks image using -build. Otherwise
     you'll need to build one yourself. Try
     $program -usage kernel
     for more information.
(10) Choose one of these tools: libio, libstdc++, gcc, g++.
(11) If you are testing the PC Simulator you will need a
    windows Target Server executable. For simplicity we'll
    assume that this is in the test tree.

Type

(embedded target)

rundeja -board <board> -tool <tool> -test <test> [-build] -verbose \\
        -host <host> -map <unix_to_windows_map>

(PC Simulator)

rundeja -board simpc -tool <tool> -test <test> [-build] -verbose \\
	-host <host> -map <unix_to_windows_map> \\
	-tgtsvr <test>

(-verbose is optional but strongly recommended the first few
times you use $program).
EOF
	    ;;
	ataman )
# ataman
	    $CAT <<EOF
Here are some hints for configuring the Ataman rsh daemon.
You can download the software from www.ataman.com.
After unzipping the executables run

atrls install start

The following settings worked for me ...

Start -> Settings -> Control Panel -> Ataman TCP RL Services
-> Users -> Add User
User Name:    			<name>
NT User Name: 			<name>
NT User Domain: 		wrs-domain
Batch Cmd Processor:		%COMSPEC% /C %COMMAND%
NT Password:			<password>
Host Equivalence List:		<ip address of unix host>
				(use the number rather than the host name)

-> Prompts
Password Prompt: set to 	Force Default
Default Response:		<password>
EOF
	    ;;
	troubleshooting )
# troubleshooting
	    $CAT <<EOF
If a dialog box pops up and the framework just keeps printing
"Waiting" its probably because the registry is full up.
Try changing the default value of WIND_REGISTRY (to "hera"
for example using -registry.)
EOF
	;;
	* )
	    $CAT <<EOF
You can get hints on the following topics:
unix      (getting started for unix testing)
windows   (getting started for windows testing)
ataman    (using the Ataman RSH server)
troubleshooting

by typing $program -hints <topic>
EOF
	    ;;
    esac
}

# Invoke the test framework
invoke_framework ()
{
    event "invoke_framework"
# Shall we rebuild the kernel, or use the existing one?
# NOTE: This must now occur before bsp Makefile is accessed
#       because Makefile does not exist until T3 project
#       is created!
    if [ -n "$must_rebuild_kernel" ]; then
	gen_kernel
    fi


    get_actual_working_dir
    change_dir $actual_working_dir
# All the executables used by the framework are provided
# by us in our workspace. Some of them may actually be
# scripts that do cunning things.
    gen_dejagnurc
    gen_site_exp
    gen_toolchain
    gen_tornado_tools

    PATH=$cwd_as_seen_from_unix:$PATH

# Fire up the Tornado registry
    start_wtxregd

    event "which windsh=`which windsh`"
    export PATH
# The expect we run is always the one that comes from
# the $wb_dejagnu tree. However we might want to put it
# in our workspace first.
    get_EXPECT
    export EXPECT
# This is the correct tcl library for expect
    TCL_LIBRARY=$dj_gnu/tcl/library
    export TCL_LIBRARY
# This is used by runtest.
    get_DEJAGNU
    export DEJAGNU
    event "Calling runtest"
    event "$dj_gnu/dejagnu/runtest --target_board $board --tool $tool --all $debug_flag $talkative_flag $other_flags"
    $dj_gnu/dejagnu/runtest --target_board $board \
			    --tool $tool \
			    --all \
			    $debug_flag $talkative_flag $other_flags
}

#####################################################################
# Process command line args
#

if [ -z "$*" ]; then
    usage;
    exit 1;
fi

while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-registry ) shift; WIND_REGISTRY=$1; setting_registry=t ;;
	-board ) shift; board=$1 ;;
	-x10 ) shift; X10_ID=$1 ;;
	-bsp ) shift; bsp=$1 ;;
	-cpu ) shift; cpu=$1 ;;
	-cflags ) shift; cflags=$1 ;;
	-ignore-rhosts ) ignore_rhosts=t;;
	-tool ) shift; tool=$1 ;;
	-root ) shift; root_working_dir=$1;;
	-test ) shift; wb_test=$1 ;;
	-kernel ) shift;  wb_kernel=$1;;
	-build ) must_rebuild_kernel=t;;
	-dejagnu ) shift; wb_dejagnu=$1;;
	-tgtsvr ) shift; wb_tgtsvr=$1;;
	-update ) shift; update_list=$1;;
	-windsh ) shift; wb_windsh=$1;;
	-host ) shift; windows_host=$1; testing_windows=t;;
	-map ) shift; unix_to_windows_map=$1; testing_windows=t;;
	-verbose ) verbose_flag=t;;
	-debug )  debug_flag=--debug;;
	-talkative ) talkative_flag="-v -v -v -v";;
	-other ) shift; other_flags=$1;;
	-instrument ) instrument=t ;;
	-usage ) shift; usage $1; exit 1 ;;
	-hints ) shift; hints $1; exit 1 ;;
	* ) usage ; exit 1;;
    esac
    shift
done


if [ -z "$verbose" ]; then
# True if we think this is a new user.
    autoverbosity=

    if [ -z "$root_working_dir" ]; then
	root_working_dir=$root_working_dir_default
    fi

    if [ ! -d "$root_working_dir" ]; then
    autoverbosity=t
    fi

    if [ ! -d $root_working_dir/sun4-solaris2 -a \
	! -d $root_working_dir/x86-linux2 -a \
	! -d $root_working_dir/x86-win32 -a \
	! -d $root_working_dir/parisc-hpux10 ]; then
	autoverbosity=t
    fi

    if [ -n "$autoverbosity" ]; then
	verbose_flag=t
	verbose "Verbosity has been automatically turned on because I think you may be"
	verbose "a new user."
    fi
fi

# Error checking and defaults

defaults="\
registry=WIND_REGISTRY=\$WIND_REGISTRY_default
board=board= \
tool=tool= \
root=root_working_dir=\$root_working_dir_default \
test=wb_test=/wind/river \
dejagnu=wb_dejagnu=\$wb_dejagnu_default \
kernel=wb_kernel=\$wb_test \
windsh=wb_windsh=\$wb_tgtsvr,\$wb_windsh_default \
tgtsvr=wb_tgtsvr=\$wb_windsh"

if [ -n "$testing_windows" ]; then
    defaults="$defaults \
host=windows_host= \
map=unix_to_windows_map= "
fi

for item in $defaults; do
    option=`echo $item | cut -f1 -d=`
    variable=`echo $item | cut -f2 -d=`
    # event "option=$option"
    # event "variable=$variable"
    if [ -z "`eval echo \\$$variable`" ]; then
	empty=t
	values=`echo $item | cut -f3 -d= | sed 's/,/ /'`
	# event "values=$values"
	if [ -n "$values" ]; then
	    for value in $values; do
		# event "value=$value"
		evaluation=`eval echo $value`
		# event "evaluation=$evaluation"
		if [ -n "$evaluation" ]; then
		    eval $variable=$evaluation
		    verbose "<$variable> defaulting to <$value> ($evaluation)"
		    empty=
		    break
		fi
	    done
	fi
	if [ -n "$empty" ]; then
	    usage $option
	    quit=t
	fi
    fi
done

# FIXME: some options are unsupported right now
#if [ -n "$board" ]; then
#case $board in
#    simsolaris|simhppa|simpc )
#	echo "I'm afraid we don't have support for the simulators yet."
#	quit=t
#	;;
#esac
#fi


# A few sanity checks

# Anything that claims to be a WIND_BASE ought to have subdirectories
# called host and target. We only check the unix ones.

if [ -n "$testing_windows" ]; then
    WIND_BASE_list="\
dejagnu=$wb_dejagnu \
windsh=$wb_windsh"
else
    WIND_BASE_list="\
test=$wb_test \
kernel=$wb_kernel \
dejagnu=$wb_dejagnu \
tgtsvr=$wb_tgtsvr \
windsh=$wb_windsh"
fi

if [ -n "$WIND_BASE_list" ]; then
# True if any of the WIND_BASE parameters are unacceptable.
    bad_WIND_BASE_found=
    for option_wb in $WIND_BASE_list; do
	option=`echo $option_wb | cut -f1 -d=`
	wb=`echo $option_wb | cut -f2 -d=`
	if [ -z "$wb" ]; then continue; fi
# Does the directory exist?
	if [ ! -d $wb ]; then
# If not, is it a view that we can start?
	    if [ -n "`echo $wb | grep '^/view/[^/]*/wind'`" ]; then
		view_tag=`echo $wb | sed 's@/view/\([^/]*\)/wind/.*@\1@'`
		verbose "Attempting to start view $view_tag ..."
		$cleartool startview $view_tag
	    fi
	fi
# Do either of the subdirectories host, target exist?
# (we don't ask that both exist because we may have generated
# the tree by copying bits and pieces from somewhere else)
	if [ ! -d $wb/host -a ! -d $wb/target ]; then
	    if [ -z "$bad_WIND_BASE_found" ]; then
		echo "The following WIND_BASE parameters are unacceptable (I can't find either"
		echo "a host or a target subdirectory)."
		bad_WIND_BASE_found=t
		quit=t
	    fi
	    echo "  -$option ($wb)"
	fi
    done
fi


# Does the user's .rhosts contain an entry for the board?
if [ -n "$board" -a -z "$ignore_rhosts" ]; then
    case $board in
	sim* ) ;;
	* )
	    rhosts=$HOME/.rhosts
# convert a name of the form tnn-mmm to nn.mmm . Because . stands
# for anything this will pick up both 147.11.22.174 and t22-174 for
# example.
	    board_regexp=`echo $board | sed 's@t\(.*\)-\(.*\)@\1.\2@'`
	    if [ -z "`grep $board_regexp $rhosts`" ]; then
		echo "You may need to include an entry for $board in $rhosts."
		echo "If for some reason this is not necessary, reinvoke $program with the"
		echo "-ignore-rhosts option."
		quit=t
	    fi
	    ;;
    esac
fi

if [ -n "$windows_host" ]; then
    if [ "`rsh $windows_host echo hello`" = "hello" ]; then
	echo "I don't think the RSH server on $windows_host is going to be very useful."
	echo "I couldn't execute rsh $windows_host echo hello."
	quit=t
    fi
fi

if [ -n "$quit" ]; then
    exit_nicely
fi


# Variables passed on the command line are expected to be suitably
# formatted before we leave this phase
get_wb_test
get_wb_tgtsvr
get_wb_kernel
get_unix_home_and_windows_home
get_update_list

# This is where all the work gets done
change_dir $root_working_dir
invoke_framework
exit_happily
